
<?php
require 'Model.php';
	class typeModel extends Model{
		function __Construct(){
			parent::__Construct();
		}
		


		function typeList(){
       
            $sql = "select * from videotype";
		    $data = $this->conn->query($sql);
			return $data;

		}	

		function deltype($id){

$sql = "delete from videotype where tid=".$id;
			$result = $this->conn->query($sql);
			return $result;

		}

		function gettypeByID($id){

				$sql = "select * from videotype where tid=".$id;
		    $result = $this->conn->query($sql);
	      	return $result;
		}

		function updatetype($data){

			$user = array(
					'typename' => trim($data['typename']),  
					
			  	);
			if(!empty($_FILES["pic"]["name"])){
  				$pic = $this->uploadfile('pic','./upload/',array('jpg','gif','png'));
  				$user['pic'] = $pic;
  				}
			  
			 		  
			 $sets = '';
			  foreach ($user as $key=>$val){
			        $sets.=$key."='".$val."',";
			    }
			    $sets=rtrim($sets,','); //去掉SQL里的最后一个逗号
			   
			    $sql="UPDATE videotype SET {$sets} where tid=".$data['id'];
			  //执行SQL语句
				$result = $this->conn->query($sql);
					return $result;
		}

	}
?>